//测试——排序算法
//编译：g++ TestSort.cpp ../../*/Sort.hpp -o test
#ifndef __TESTSORT__CPP
#define __TESTSORT__CPP

#include<iostream>
#include<cstdlib>
#include<ctime>
#include"../../Algorithm/Sort.hpp"

using namespace std;
using namespace NgSiuKei;

bool arrayIsSequential(int *array, int size) {
    for(int i=0; i<size-1; ++i) {
        if(array[i] > array[i+1]) {
            return false;
        }
    }
    return true;
}

int main(void) {
    srand(time(0));

    clock_t start, finish;
    double  duration;

    const int size = 10;
    int array[size] = {0};
    for(int i=0; i<size; ++i) {
        array[i] = rand()%(size*10)+1;
    }

    cout << "排序前：[ ";
    for(int i=0; i<size; ++i) {
        cout << array[i] << ' ';
    }
    cout << ']' << endl;

    start = clock();
    bubbleSort(array, size); //冒泡排序
    // selectionSort(array, size); //选择排序
    // insertionSort(array, size); //插入排序
    // shellSort(array, size); //希尔排序
    // mergeSort(array, size); //归并排序
    // quickSort(array, size); //快速排序
    // bucketSort(array, size); //桶排序
    // countingSort(array, size); //计数排序
    // radixSort(array, size); //基数排序
    // heapSort(array, size); //堆排序
    finish = clock();
    duration = (double)(finish - start);// / CLOCKS_PER_SEC;

    cout << "排序后：[ ";
    for(int i=0; i<size; ++i) {
        cout << array[i] << ' ';
    }
    cout << ']' << endl;
    cout << "结果：" << ((arrayIsSequential(array, size))?("成功"):("失败")) << endl;
    cout << "用时：" << duration << "毫秒" << endl;

    return 0;
}

#endif